<?php
// $Id: contact_form_on_node.admin.inc,v 1.1.4.1 2010/11/24 00:18:34 tahiticlic Exp $

/**
 * @file contact_form_on_node.admin.inc
 * Functions that are only called on the admin pages.
 */

/**
 * Module settings form.
 */
function contact_form_on_node_settings() {

  $form['contact_form_on_node_info'] = array(
    '#value' => t('<p>The contact_form_on_node module allows you to display a contact form right under a node</p>')
    );
	
    
  // General settings.
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    ); 
	$form['general']['contact_form_on_node_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Contact form to use'),
    '#description' => t("Select the contact form to use - by default, the user's contact form is used."),
    '#default_value' => variable_get('contact_form_on_node_mode', CONTACT_FORM_ON_NODE_MODE_USER),
    '#options' => array(
      CONTACT_FORM_ON_NODE_MODE_USER => t("User's contact form"),
      CONTACT_FORM_ON_NODE_MODE_SYSTEM => t("System-wide contact form"),
    )
  );
  
  $form['general']['contact_form_on_node_show_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add a link to contact the author in full view?'),
    '#default_value' => variable_get('contact_form_on_node_show_link', FALSE),
    '#description' => t('Should we add a link to contact the author from his contact page?'),
    );
    
   $form['general']['contact_form_on_node_show_form'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add a form to contact the author in full view?'),
    '#default_value' => variable_get('contact_form_on_node_show_form', TRUE),
    '#description' => t('Should we add a form to contact the author directly from the node?'),
    );  
    
   $form['general']['contact_form_on_node_show_link_in_teaser'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add a link to contact the author in teaser view?'),
    '#default_value' => variable_get('contact_form_on_node_show_link_in_teaser', TRUE),
    '#description' => t('Should we add a link to contact the author from his contact page, when viewing teaser of the node?'),
    );
    
    $form['general']['contact_form_on_node_show_form_in_teaser'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add a form to contact the author in teaser view?'),
    '#default_value' => variable_get('contact_form_on_node_show_form_in_teaser', FALSE),
    '#description' => t('Should we add a form to contact the author directly from the node, when viewing teaser of the node?'),
    );  
             
  // Types settings.
  $form['types'] = array(
    '#type' => 'fieldset',
    '#title' => t('Types'),
  	'#collapsible' => TRUE,
    '#collapsed' => FALSE,
    );    
    
  $select = array();
  $types = node_get_types();
  $names = node_get_types('names');
  foreach ($types as $key => $type) {
    $select[$key] = $names[$key];
  } 
  $form['types']['contact_form_on_node_types'] = array(
    '#title' => t('Included Types'),
    '#type' => 'checkboxes',
    '#default_value' => variable_get('contact_form_on_node_types', array()),
    '#options' => $select,
    '#description' => t('Select here which node types you want a contact form/link to be added to.'),
    '#prefix' => '<div class="contact_form_on_node_checkboxes">',
    '#suffix' => '</div>',
    );  
    
  return system_settings_form($form);
}